<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Bill extends Model
{
    protected $table = 'bill';
    protected $guarded = [];

    public function order(){
        return $this->belongsTo(Order::class,'order_sn','order_sn');
    }

    public static function billAdd($order_sn,$userId,$amount,$type){
        //记录消费
        $bill = new Bill();
        $bill->order_sn = $order_sn;
        $bill->userid = $userId;
        $bill->money = $amount;
        $bill->type = $type;
        $bill->status = 1;
        $bill->save();
    }
}
